﻿using System;
using System.Collections.Generic;
using RoleDataAuth = BotonJXC.Entity.RoleDataAuth;
using RoleDataAuthDAO = BotonJXC.DAO.RoleDataAuthDAO;
using BotonJXC.Util;
using NHibernate.Criterion;

namespace BotonJXC.BLL
{
    public class RoleDataAuthBLL : BaseBLL<RoleDataAuthDAO, RoleDataAuth, int>
    {
        public RoleDataAuthBLL()
        {
        }

        public IList<RoleDataAuth> FindByRoleId(int roleId)
        {
            List<ICriterion> criterions = new List<ICriterion>();
            criterions.Add(Restrictions.Eq("RoleId", roleId));
            return Dao.Find(criterions.ToArray());
        }

        public void Save(int roleId, IList<RoleDataAuth> dataAuths)
        {
            Dao.DeleteByRoleId(roleId);
            foreach (RoleDataAuth rda in dataAuths)
                Save(rda);
        }
    }
}